﻿function confirm_delete(url) {
	if (confirm("Anda yakin akan menghapus?")) {
		document.location = url;
	}else{
		//document.location = '';
	}
}

$(document).ready(function(){
    $("#user_name").keyup(function(){
        if($("#user_name").val().length >= 1){
			$.ajax({
				type: "POST",
				url: baseUrl + "users/check_username_exist",
				//data: "name="+$("#user_name").val(),
				data: $.param({
								name:$("#user_name").val(),
								id:$("#id_user").val()
							}),
				dataType:'json',
				success: function(msg){
					if(msg=="true"){
						$("#usr_verify").removeClass('verify-failed');
						$("#usr_verify").addClass('verify-success').html('<img src="'+ baseUrl + 'images/site_icon/ok.png">Username yang anda masukkan valid');
						$("#reg-submit").removeClass('button-disabled').attr('disabled', false);
					}else{
						$("#usr_verify").removeClass('verify-success');
						$("#usr_verify").addClass('verify-failed').html('<img src="'+ baseUrl + 'images/site_icon/delete.png">Username yang anda masukkan sudah dipakai');
						$("#reg-submit").addClass('button-disabled').attr('disabled', true);
					}
				}
			});
        } else {
            $("#usr_verify").css({ "background-image": "none" });
        }
    });
});